package com.hue.test;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class UserController {
    public void test(String name, String age) {
        System.out.println(name + "," + age);
    }

    public static void main(String[] args) {
        try {
            Class<?> aClass = Class.forName("com.hue.test.UserController");
            Object bean = aClass.newInstance();
            Method[] methods = aClass.getDeclaredMethods();
            for(Method method:methods){
                if (method.getName().equals("test")) {
                    Class<?>[] parameterTypes = method.getParameterTypes();
                    Object objs[] = new Object[parameterTypes.length];
                    objs[0] = "yao";
                    objs[1] = "20";
                    method.invoke(bean, objs);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
